import { Enum } from "cc";

export class Constant {

    public static GAME_NAME = 'Coin';

    public static GAME_VERSION = '1.0.1';

    public static GAME_FRAME = 60;      //游戏当前帧率
    public static GAME_INIT_FRAME = 60; //
    public static GAME_NAME_CH: "别动我的金币";

    //本地缓存key值
    public static LOCAL_CACHE = {
        PLAYER: 'player',               //玩家基础数据缓存，如金币砖石等信息，暂时由客户端存储，后续改由服务端管理
        SETTINGS: 'settings',           //设置相关，所有杂项都丢里面进去
        DATA_VERSION: 'dataVersion',    //数据版本
        ACCOUNT: 'account',                 //玩家账号
        // TMP_DATA: 'tmpData',             //临时数据，不会存储到云盘
        HISTORY: "history",                   //关卡通关数据
        BAG: "bag",                         //玩家背包，即道具列表，字典类型
    }

    static PTM_RATIO = 1;

    static GAME_OBJ_TYPE = { // 二进制位
        PLAYER: 1,
        COIN: 2
    };

    static ACTION = {
        MOVE: 1,
        STOP_MOVE: 2,
        GAME_START: 3,
        GAME_OVER: 4,
        READY: 5,
        HEART_BEAT: 6,
        HIT: 7,
        UPDATE_POS: 8,
        VIBRATE: 9,
        GIFT: 10,
    }

    static NETWORK_STATUS = {
        COMMON_OFFLINE: 0,
        COMMON_ONLINE: 1,
        RELAY_OFFLINE: 2,
        RELAY_ONLINE: 3,
    }

    static CUSTOM_PLAYER_STATUS = {
        UNCONNECTED: 0,
        CONNECTED: 1,
        READY: 2, 
        GAME: 3,
    }

    static FRAME_SYNC_STATE = {
        STOP: 0,
        START: 1 
    }

    static COIN_TYPE = Enum({
        COIN: 1,
        PROP: 2
    });

    static ADD_SIZE_PER_COIN = 0.03;   //每1个金币 体积增加 5%
    static ADD_SPEED_PER_COIN = -0.01;  //每一个金币 移动速度减少 1%
    static MIN_SPEED_PERCENT = 0.5;     //最低速度百分比

    static INIT_MOVE_SPEED = 20;    //初始移动速度

    static INIT_COLLIDER_CIRCLE = 0.8; //初始的人物碰撞矩形框

    static GAME_TIME = 60;      //游戏时间60秒

    static HAMMER_TIMES = 1;    //锤子可用次数

    static REVIVE_TIME = 0.5;   //复活时间

    static AUTO_GEN_COIN = {  //自动生成金币相关
        SECOND_PER_TIMES: 1,    //每多少秒触发一次
        COIN_PER_TIMES: 3,      //每次生成几个金币
        START_NUM: 10,          //金币数量小于指定个数，开始自动生成
        END_NUM: 30             //金币数量大于指定个数，停止生成
    }

    static HAMMER_TIME = 3;   //锤头生成时间

    static MIN_PLAYER = 2;//玩家最少人数
    static MAX_PLAYER = 2;//玩家最多人数
    static PAUSE_COUNTDOWN = 10;//暂停界面倒计时
    
    static EVENT_NAME = {
        ON_GET_ROOM_INFO: 'onGetRoomInfo', //获取到房间信息
        ON_GET_ROOM_ID: 'onGetRoomId', //获取到房间ID
        ON_START_FRAME_SYNC:'onStartFrameSync', //开始帧同步
        ON_STOP_FRAME_SYNC:'onStopFrameSync', //停止帧同步
        ON_RECV_SYNC:'onRecvSync', //帧同步数据
        ON_GAME_START: 'onGameStart',    //开始游戏
        ON_GAME_END: 'onGameEnd',    //结束游戏
        ON_SHOW_COIN_TIPS: "showCoinTips", //显示金币提示
        ON_DEBUG_GAME_STATE: "打印gameState信息",

        ON_RECV_FROM_CLIENT:"onRecvFromClient", // 来自其他客户端的消息
        ON_ROUND_TIME_OUT:"onRoundTimeOut", // 回合超时

    }

    static PANEL_NAME = {
        READY: 'fight/ready',      //准备界面 
        GAME_OVER: 'fight/gameOver',//结算界面 
        FIGHT_UI: 'fight/fightUI', //结算界面 
        READY_GO: 'fight/readyGo' //结算界面 
    }

    static AUDIO_NAME = {
        BACKGROUND: 'background',      //背景音乐 
        WIN: 'win', //胜利音效 
        GO: 'go',   //游戏开始音效
        TICK: 'tick',    //倒计时音效
        TIME_OUT: 'timeout', //时间到音效
        GOLD: 'gold' ,//金币音效
        HIT: 'hit',                     //击中音效
    }
    

    static EFFECT_NAME = {
        HAMMER_DISAPPEAR: 'hammerdisappear',    //锤头消失   
        RUNNING: 'running',                     //跑步特效
        HIT: 'hitNew',                     //击中特效
    }

    static ROOM_TIPS = {
        CREATE: "创建房间。。。",
        WAITING: "请稍等，房主正在创建房间。。。",
        LEAVE: "您的对手已经离开房间。。。",
        IN_ROOM: "已在房间内。。。",
        CREATE_ROOM_ERROR: "创建房间失败。。。",
        JOIN_ROOM_ERROR: "加入房间失败。。。",
    }

    static EVENT_MAP = {
        INIT_PIECES: 'initPieces', //初始化棋子
        ON_GET_ROOM_ID: 'onGetRoomId', //获取到房间ID
    }

    static FIGHT_UI = {
        INIT_FIGHT_PLAYER: 'initFightPlayer', //初始化开局界面
        ON_COUNT_DOWN_START: 'onStartTimeCutDown', //倒计时
        ON_COUNT_DOWN_STOP: 'onStopTimeCutDown', //倒计时
    }

}
